﻿using B.S.Sterilizationcenter.Domain.zmc;
using B.S.Sterilizationcenter.ErrorCode;
using B.S.Sterilizationcenter.Read.API.Appliaction.Commends.zmc.Instrumentkit;
using MediatR;
using SqlSugar;

namespace B.S.Sterilizationcenter.Read.API.Appliaction.CommandHandlers.zmc.Instrumentkit
{
    public class QueryInstrumentkitByIdCommendHandlers : IRequestHandler<QueryInstrumentkitByIdCommends, ApiResult<List<Instrumentkits>>>
    {

        private readonly ISqlSugarClient db;

        public QueryInstrumentkitByIdCommendHandlers(ISqlSugarClient db)
        {
            this.db = db;
        }
        /// <summary>
        /// 根据id查询数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiResult<List<Instrumentkits>>> Handle(QueryInstrumentkitByIdCommends request, CancellationToken cancellationToken)
        {
            ApiResult<List<Instrumentkits>> result = new ApiResult<List<Instrumentkits>>();
            result.Code = ApiEnums.查询成功;
            result.Msg = "查询成功";

            var list = db.Queryable<Instrumentkits>().Where(it => it.InstrumentkitsId == request.InstrumentkitsId).ToList();

            result.Data = list;

            return result;
        }
    }
}
